package yartiss.service.model;

import java.util.ArrayList;
import java.util.List;

import yartiss.engine.simulation.Event;
import yartiss.engine.simulation.IEventAddedListener;


public abstract class AbstractEventsModel implements IEventsModel{

	private final List<IEventAddedListener> listeners = new ArrayList<IEventAddedListener>();

	/**
	 * 
	 */
	@Override
	public void addEventAddedListener(IEventAddedListener l) {
		if(!listeners.contains(l))	
			listeners.add(l);
	}

	/**
	 * 
	 */
	@Override
	public void removeEventAddedListener(IEventAddedListener l) {
		if(listeners.contains(l))	
			listeners.remove(l);
	}
	
	/**
	 * 
	 * @param e
	 */
	protected void fireEventAdded(Event e){
		for (IEventAddedListener l : listeners) {
			l.perfomredAction(e);
		}
	}
	
	
}
